Skip to content

crypto: RFC 9001 Appendix A.1 to A.4 (QUIC packet protection) as tests on every AES-GCM backend - #24

Merged
pinhopro merged 1 commit into
mainfrom
crypto/rfc9001-tests
Dec 4, 2026
Merged

pinhopro merged 1 commit into
mainfrom
crypto/rfc9001-tests

Conversation

@pinhopro

@pinhopro pinhopro commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

RFC 9001 (QUIC-TLS) Appendix A as interop tests: proof, with the RFC's published vectors, that webcpp::crypto (with webcpp::hash's HKDF) does QUIC version 1's packet protection byte for byte. This is the owner's 2026-12-01 decision: the roadmap item "crypto aes128-gcm" shrank to these tests, since ciphers::aes128_gcm already exists. It adds tests only. There is no QUIC API and no new public function. Design: webcpporg/proposals, libraries/crypto/openspec/changes/rfc9001-tests (rulings R1 to R9).

  • test/support/quic_rfc9001_vectors.hpp: RFC 9001 section 5.2's initial salt, section 5.8's Retry key and nonce, and Appendix A.1 to A.4, copied from the RFC Editor's text. Each value names its section, and a script confirmed that every hex string occurs in the RFC.
  • test/support/quic_rfc9001.hpp: the checks, as templates over the AEAD (gcm<aes128<B>>) and the header protection's block cipher (aes128<B>):
    • A.1: the five HkdfLabels, the initial secret, and both directions' secrets, keys, IVs and hp keys. TLS 1.3's HKDF-Expand-Label is written in the test, as hash::hkdf_expand over pieces {length, label length, "tls13 ", label, 0}.
    • A.2 and A.3: both Initial packets, in both directions. Protecting gives the RFC's packet: seal with iv XOR packet number, then mask with AES-ECB(hp, sample) through the public aes128<B>::encrypt on one block. Unprotecting gives back the RFC's header and payload; the packet number length is read from the unmasked first byte.
    • A packet with one bit flipped: authentication_failed, and the payload is zeroed.
    • A.4: the Retry integrity tag is sealed and opened. With another original connection ID, the open is refused.
  • Three programs, each also _no_exceptions:
    • quic_rfc9001_openssl: OpenSSL for both the AEAD and the block; native, wasip2, wasip3.
    • quic_rfc9001_bearssl: BearSSL for GCM and ctaes for the block, since BearSSL has none; every target, Emscripten included.
    • quic_rfc9001_default: aes128_gcm and aes128<>; every target.
  • doc/tables/crypto.json names the new tests as evidence for gcm (OpenSSL, BearSSL) and aes_block (OpenSSL, ctaes). generate.py regenerated the pages.

What is not covered: A.5 (ChaCha20-Poly1305 short header). crypto exposes the AEAD but not raw ChaCha20, which A.5's header protection needs. A.5 joins with the planned ciphers::chacha20 of the change primitives.

Verified locally:

  • clang (macOS) and gcc-15: 6 of 6 passed.
  • wasip2 and wasip3: 6 of 6 passed.
  • Emscripten: 4 of 4 passed. OpenSSL is not built there.
  • MSVC 14.3 and 14.5 x64 debug (msvc-lane): 6 of 6 passed each, 0 new failures.
  • The checks seen failing first: one byte changed in the Retry key and in A.2's mask, and the run failed on exactly those checks.
  • generate.py --check, generate_test.py and tools/test/crypto_jamfiles_test.py: ok.
  • macOS clang-format and clang-tidy: clean. Linux lint (CI's lint job in Docker): CLEAN.

🤖 Generated with Claude Code

…ion, as tests on OpenSSL, on BearSSL with ctaes for the block and on the defaults, with no QUIC API; the capability table names them
@pinhopro
pinhopro merged commit 7253893 into main Dec 4, 2026
73 of 76 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant